function varargout = embed_detect(varargin)
% EMBED_DETECT MATLAB code for embed_detect.fig
%      EMBED_DETECT, by itself, creates a new EMBED_DETECT or raises the existing
%      singleton*.
%
%      H = EMBED_DETECT returns the handle to a new EMBED_DETECT or the handle to
%      the existing singleton*.
%
%      EMBED_DETECT('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in EMBED_DETECT.M with the given input arguments.
%
%      EMBED_DETECT('Property','Value',...) creates a new EMBED_DETECT or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before embed_detect_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to embed_detect_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help embed_detect

% Last Modified by GUIDE v2.5 13-Sep-2011 12:58:16

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @embed_detect_OpeningFcn, ...
                   'gui_OutputFcn',  @embed_detect_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT


% --- Executes just before embed_detect is made visible.
function embed_detect_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to embed_detect (see VARARGIN)

% Choose default command line output for embed_detect
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);
set(handles.funcsel, 'SelectionChangeFcn', @funcsel_SelectionChangeFcn);
% UIWAIT makes embed_detect wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = embed_detect_OutputFcn(hObject, eventdata, handles) 
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;



function editinputfile_Callback(hObject, eventdata, handles)
% hObject    handle to editinputfile (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of editinputfile as text
%        str2double(get(hObject,'String')) returns contents of editinputfile as a double


% --- Executes during object creation, after setting all properties.
function editinputfile_CreateFcn(hObject, eventdata, handles)
% hObject    handle to editinputfile (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in jsteg.
function jsteg_Callback(hObject, eventdata, handles)
% hObject    handle to jsteg (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of jsteg


% --- Executes on button press in f3.
function f3_Callback(hObject, eventdata, handles)
% hObject    handle to f3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of f3


% --- Executes on button press in f4.
function f4_Callback(hObject, eventdata, handles)
% hObject    handle to f4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of f4


% --- Executes on button press in f5.
function f5_Callback(hObject, eventdata, handles)
% hObject    handle to f5 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of f5


% --- Executes on button press in radiobutton5.
function radiobutton5_Callback(hObject, eventdata, handles)
% hObject    handle to radiobutton5 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of radiobutton5


% --- Executes on button press in radiobutton6.
function radiobutton6_Callback(hObject, eventdata, handles)
% hObject    handle to radiobutton6 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of radiobutton6


% --- Executes on button press in radiobutton7.
function radiobutton7_Callback(hObject, eventdata, handles)
% hObject    handle to radiobutton7 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of radiobutton7


% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)



function editModel_Callback(hObject, eventdata, handles)
% hObject    handle to editModel (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of editModel as text
%        str2double(get(hObject,'String')) returns contents of editModel as a double


% --- Executes during object creation, after setting all properties.
function editModel_CreateFcn(hObject, eventdata, handles)
% hObject    handle to editModel (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function editoutputdir_Callback(hObject, eventdata, handles)
% hObject    handle to editoutputdir (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of editoutputdir as text
%        str2double(get(hObject,'String')) returns contents of editoutputdir as a double


% --- Executes during object creation, after setting all properties.
function editoutputdir_CreateFcn(hObject, eventdata, handles)
% hObject    handle to editoutputdir (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on button press in pushbutton5.
function pushbutton5_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton5 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)



function editinputdir_Callback(hObject, eventdata, handles)
% hObject    handle to editinputdir (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of editinputdir as text
%        str2double(get(hObject,'String')) returns contents of editinputdir as a double


% --- Executes during object creation, after setting all properties.
function editinputdir_CreateFcn(hObject, eventdata, handles)
% hObject    handle to editinputdir (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function editoutputfile_Callback(hObject, eventdata, handles)
% hObject    handle to editoutputfile (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of editoutputfile as text
%        str2double(get(hObject,'String')) returns contents of editoutputfile as a double


% --- Executes during object creation, after setting all properties.
function editoutputfile_CreateFcn(hObject, eventdata, handles)
% hObject    handle to editoutputfile (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function editmsg_Callback(hObject, eventdata, handles)
% hObject    handle to editmsg (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of editmsg as text
%        str2double(get(hObject,'String')) returns contents of editmsg as a double


% --- Executes during object creation, after setting all properties.
function editmsg_CreateFcn(hObject, eventdata, handles)
% hObject    handle to editmsg (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

function methodsel_SelectionChangeFcn(hObject, eventdata)
%retrieve GUI data, i.e. the handles structure
handles = guidata(hObject); 
global method
method = get(eventdata.NewValue,'Tag');
%updates the handles structure
guidata(hObject, handles);

function funcsel_SelectionChangeFcn(hObject, eventdata)

%retrieve GUI data, i.e. the handles structure
handles = guidata(hObject); 
global func;
func = get(eventdata.NewValue,'Tag');

switch get(eventdata.NewValue,'Tag')   % Get Tag of selected object
    case 'hideone'
      set(handles.result,'String','Hideone');
      set(handles.methodsel,'Visible','on');
      set(handles.featuresel,'Visible','off');
      set(handles.inputfile,'Visible','on');
      set(handles.outputfile,'Visible','on');
      set(handles.inputdir,'Visible','off');
      set(handles.outputdir,'Visible','off');
      set(handles.message,'Visible','on');
      set(handles.modelfile,'Visible','off');
      
    case 'hidelist'
      set(handles.result,'String','Hidelist');
      set(handles.methodsel,'Visible','on');
      set(handles.featuresel,'Visible','off');
      set(handles.inputfile,'Visible','off');
      set(handles.outputfile,'Visible','off');
      set(handles.inputdir,'Visible','on');
      set(handles.outputdir,'Visible','on');
      set(handles.message,'Visible','off');
      set(handles.modelfile,'Visible','off');

    case 'extract'
      set(handles.result,'String','Extract');
      set(handles.methodsel,'Visible','on');
      set(handles.featuresel,'Visible','off');
      set(handles.inputfile,'Visible','on');
      set(handles.outputfile,'Visible','on');
      set(handles.inputdir,'Visible','off');
      set(handles.outputdir,'Visible','off');
      set(handles.message,'Visible','off');
      set(handles.modelfile,'Visible','off');
      
    case 'feature'
      set(handles.result,'String','Feature');
      set(handles.methodsel,'Visible','off');
      set(handles.featuresel,'Visible','on');
      set(handles.inputfile,'Visible','off');
      set(handles.outputfile,'Visible','off');
      set(handles.inputdir,'Visible','on');
      set(handles.message,'Visible','off');
      set(handles.modelfile,'Visible','off');
      set(handles.outputdir,'Visible','off');
      
    case 'predict'
      set(handles.result,'String','Predict');
      set(handles.methodsel,'Visible','off');
      set(handles.featuresel,'Visible','on');
      set(handles.inputfile,'Visible','on');
      set(handles.outputfile,'Visible','off');
      set(handles.inputdir,'Visible','off');
      set(handles.outputdir,'Visible','off');
      set(handles.message,'Visible','off');
      set(handles.modelfile,'Visible','on');

    case 'train'
      set(handles.result,'String','Train');
      set(handles.methodsel,'Visible','off');
      set(handles.featuresel,'Visible','off');
      set(handles.inputfile,'Visible','off');
      set(handles.outputfile,'Visible','off');
      set(handles.inputdir,'Visible','on');
      set(handles.outputdir,'Visible','off');
      set(handles.message,'Visible','off');
      set(handles.modelfile,'Visible','on');
      
        otherwise
       % Code for when there is no match.

end
%updates the handles structure
guidata(hObject, handles);

% --- Executes on button press in btnexit.
function btnexit_Callback(hObject, eventdata, handles)
% hObject    handle to btnexit (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in btnrun.
function btnrun_Callback(hObject, eventdata, handles)
% hObject    handle to btnrun (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

%retrieve GUI data, i.e. the handles structure
handles = guidata(hObject); 

global func;
global method;
switch func
    case 'hideone'
        set(handles.result,'String',sprintf('Use %s to hide messages in %s...',method,inpath));
        inpath = get(handles.editinputfile,'String');
        outpath = get(handles.editoutputfile,'String');
        msg = get(handles.editmsg,'String');
        
        switch method
            case 'jsteg'
                testjsteg(inpath, msg, outpath);
            case 'f3'
                testf3(inpath, msg, outpath);
            case 'f4'
                testf4(inpath, msg, outpath);
            case 'f5'
                testf5(inpath, 2, msg, outpath);
            otherwise
        end
        
        set(handles.result,'String',sprintf('Hidden to %s.',outpath));
        
    case 'hidelist'
    case 'extract'
    case 'feature'
    case 'predict'
    case 'train'
    otherwise
       % Code for when there is no match.
end
%updates the handles structure
guidata(hObject, handles);
